<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>系统首页</title>
    <link rel="stylesheet" href="{$CSS}/bootstrap3.3.7.min.css">
    <style>
        td,th{
			text-align: center;vertical-align: middle !important;
			}
        .paging{
           list-style:none;
           display:inline ;
           padding-left:2px    
        }
/*
        .paging:after{
            content:"";
            clear: both
        }
*/
        .paging li{
            display:inline-block
        }
        .paging a{
            padding:5px 10px;
            border: 1px solid #ddd;
            margin-left: -1px;
            text-decoration: none;
        }
        .active{
            border-color: #337ab7 !important;
        }
    </style>
</head>

<body>
    <div style="padding:10px;border-bottom:1px solid #eee;font-size:15px;font-weight:700">代理用户管理</div>
    <div style="padding:20px">
        <form class="form-inline" method="get" action="daililiebiaozuofei.html" name="Form" id="Form1">
            <div class="form-group">
                <label for="exampleInputName2">姓名</label>
				{$tj->text('name','class="form-control" placeholder="姓名"')}
            </div>
            <div class="form-group">
                <label for="exampleInputName2">帐号</label>
				{$tj->text('un','class="form-control" placeholder="账号"')}
            </div>
			{if $mu->isyg || $mu->isadmin}
			 <div class="form-group">
                <label for="exampleInputEmail2">类型</label>
				{$tj->select($dl_arr,'level','class="form-control"')}
            </div>
			{/if}
            <button type="submit" class="btn btn-primary">查询</button>
            <button type="button" class="btn btn-primary" onclick="tostart('a',this)" id="del">启用</button>
            <button type="button" class="btn btn-danger" onclick="todel('a',this)" id="del">删除</button>
        </form>
        <div style="margin-top:15px">
            <table class="table table-bordered table-hover">
              <thead>
                <tr>
                  <th>ID</th>
                  <th>账号</th>
                  <th>名称</th>
                  <th>类型</th>
                  <th>开户时间</th>
                  <th>余额(￥)</th>
                  <th>手机</th>
                 <!-- <th>套数</th>-->
                  <th>所属员工(代理)</th>
                  <th>状态</th>
                  <th class="col-md-3">操作</th>
                </tr>
              </thead>
              <tbody>
			{loop $res as $r}
                <tr>
                  <td scope="row"><input type='checkbox' name='checkbox' value='{$r->id}' />{$r->id}</td>
                  <td><a href="xinzengdaili-{$r->id}.html">{$r->un}</a></td>
                  <td>{$r->name}</td>
                  <td>{$dl_arr[$r->level]}</td>
                  <td>{$r->rtime}</td>
                  <td>{$r->yue}</td>
                  <td>{$r->telephone}</td>
                  <!--<td>{taoshul($r)}</td>-->
                  <td>{$agency_arr[$r->pid]}</td>
                  <td><span style="color:red;">作废</span></td>
                  <td>
					   <a class="btn btn-info btn-sm" href="javascript:tochongzhi({$r->id});">充值</a>
					   <a class="btn btn-success btn-sm" href="lowerAgency-{$r->id}-{md5($r->id.$mu->pwd)}.html">下级代理</a>
					   <a class="btn btn-success btn-sm" href="/weidogsadmin/user/lowerUser-{$r->id}-{md5($r->id.$mu->pwd)}.html">下级用户</a>
                      <a class="btn btn-primary btn-sm" href="xinzengdaili-{$r->id}.html">编辑 &nbsp;|&nbsp; 查看</a>
                  </td>
                </tr>
			{/loop}
              </tbody>
            </table>
        </div>
        <div>
            <div style="display: inline-block">
                <span>{$p->totalnum}条/{$p->totalpage}页</span> 
            </div>
			<ul class="paging">
           {P weidogsadmin}
			</ul>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
function tostart(id,o){
	if(id=='a'){
		var ids = [];
		$('td').find('input[type="checkbox"]:checked').each(function(){
			ids[ids.length] = $(this).val();
		});
		if(ids.length == 0){
			tusi('请选择！');
			return false;
		}
		if(confirm('确定启用这些代理吗？')){
			ajax('dailicaozuo-start.html',{ id:ids.join(',')},function(data){
				if(data == 'ok'){
					tusi('操作成功');
					setTimeout(function(){
						goto(location.href);
					},500);
				}
			});	
		}
	}
}

function todel(id,o){
	if(id=='a'){
		var ids = [];
		$('td').find('input[type="checkbox"]:checked').each(function(){
			ids[ids.length] = $(this).val();
		});
		if(ids.length == 0){
			tusi('请选择！');
			return false;
		}
		if(confirm('确定彻底删除这些代理吗？')){
			ajax('dailicaozuo-reldel.html',{ id:ids.join(',')},function(data){
				if(data == 'ok'){
					tusi('操作成功');
					setTimeout(function(){
						goto(location.href);
					},500);
				}
			});	
		}
	}
}
function tochongzhi(id){
	pophtml('<iframe id="jd_iframe" src="dailichongzhi-'+id+'.html" scrolling="auto" frameborder="0" width="370" height="185"></iframe>',410,265,null,0,1);
}
</script>